package com.lantu.core.mapper;


import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lantu.core.entity.Member;
import com.lantu.dto.member.MemberPageDTO;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author binyuhuang
 * @since 2023-02-07
 */
public interface MemberMapper extends BaseMapper<Member> {

    default Page<Member> selectPage(MemberPageDTO dto){
        Page<Member> page = new Page<>(dto.getPageNo(), dto.getPageSize());
        return selectPage(page, new LambdaQueryWrapper<Member>()
                .eq(StrUtil.isNotBlank(dto.getUsername()), Member::getUsername, dto.getUsername())
                .eq(StrUtil.isNotBlank(dto.getPhone()), Member::getPhone, dto.getPhone())
                .eq(StrUtil.isNotBlank(dto.getEmail()), Member::getEmail, dto.getEmail())
                .eq(ObjectUtil.isNotEmpty(dto.getStatus()), Member::getStatus, dto.getStatus())
        );
    }
}
